<?php

class sys{
	public static function _print_r($v,$left=-1,$ret="My"){
		$left+=1;
		if (is_array($v) ){
			return self::arrayToString($v,$left,$ret);
		} 
		return   $ret.$v."\n";	 
	}

	public static function arrayToString($v,$left,$ret){	
			$ret.="Array\n".str_repeat('  ',$left*4)."(\n";
			foreach ($v as $key=>$val)
			{
				$parmret=$ret.str_repeat('  ',$left*4+2)."[$key] => ";
				$ret=self::recursionPrintR($val,$left,$parmret)	;			 
			}
			 $ret.=str_repeat('  ',$left*4).")\n\n";	
		 return $ret;
	}
 
//递归调用_print_r
	public static function recursionPrintR($val,$left,$ret){	
		if (is_array($val)){
			return self::_print_r($val,$left,$ret);
		}
			return $ret."$val\n";	 		 	
	}
	public static function print_r($v,$left=-1,$ret="My"){
	    echo self::_print_r($v,$left,$ret);
	}
}
?> 